package com.dotools.utils;

import android.content.Context;

import java.lang.reflect.Method;

public class SysPwdUtils {
    
    /**
     * 判断是否拥有系统密码
     * @param context
     * @return
     */
    public static boolean hasSysPassword(Context context){
        boolean hasPwd = false;
        String classPath = "com.android.internal.widget.LockPatternUtils";
        try {
            Class<?> lockPatternClass = Class.forName(classPath);
            Object lockPatternObject = lockPatternClass.getConstructor(Context.class).newInstance(context);
            Method method = lockPatternClass.getMethod("isSecure");
            hasPwd = (Boolean) method.invoke(lockPatternObject);
        } catch (Exception e) {
            hasPwd = false;
        }
        return hasPwd;
    }

}
